﻿using Prism.Services.Dialogs;
using System.Collections.Generic;
using DistributedVisionRunner.Module.Models;

namespace DistributedVisionRunner.Module.ViewModels
{
    public class VisionProcessUnitPropertyDialogViewModel : DialogViewModelBase
    {
        private IEnumerable<PropertyItem> _properties;
        public IEnumerable<PropertyItem> Properties
        {
            get => _properties;
            set => SetProperty(ref _properties, value);
        }

        public override void OnDialogOpened(IDialogParameters parameters)
        {
            var output = new List<PropertyItem>();
            foreach (var name in parameters.Keys)
            {
                var propValue = parameters.GetValue<string>(name);
                
                if (!string.IsNullOrEmpty(propValue)) output.Add(new PropertyItem { Name = name, Value = propValue });
            }

            Properties = output;
        }
    }
}
